package org.wk.affiliate.controller;

import com.google.common.base.Verify;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.wk.affiliate.service.NotifyService;
import org.wk.affiliate.view.NotifyVo;
import org.wk.core.common.view.ResponseVo;
import org.wk.user.domain.User;
import org.wk.user.service.UserService;

import java.util.List;
import java.util.Map;

/**
 * @author TangShenShen
 * @Description: 通知管理controller类
 * @date 2018/6/12  10:46
 */
@RestController
@RequestMapping("/notify")
public class NotifyController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private UserService userService;
    @Autowired
    private NotifyService notifyService;

    @RequestMapping(value="/userSearch/list")
    public ResponseVo list(@RequestParam Map<String, Object> params) {
        List<User> list = userService.getAllByParams(params);
        return ResponseVo.success().setData(list);
    }

    /**
     * @description 保存通知并推送给用户
     * @param
     * @author ZhaoPing'an
     * @date 2018/7/9 16:15
     */
    @RequestMapping(value="/userSearch/sendPush")
    public ResponseVo sendPush(@RequestBody NotifyVo notifyVo) {
        notifyService.saveAndSendPush(notifyVo);
        return ResponseVo.success();
    }


}
